package com.jic.order.controller.manage;

import com.jic.common.base.vo.RestResult;
import com.jic.order.entity.OrderDeliverDetail;
import com.jic.order.request.OrderDeliverDetailRequest;
import com.jic.order.request.OrderDeliverQueryPage;
import com.jic.order.request.SendGoodsRequest;
import com.jic.order.response.OrderDeliverInfo;
import com.jic.common.base.vo.PageResult;
import com.jic.order.service.OrderOperateService;
import com.jic.order.service.OrderQueryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Api(tags = {"后台-交货单管理"})
@RequestMapping(value = "deliverManager")
@RestController
public class OrderDeliverManagerController {

    @Autowired
    private OrderQueryService orderQueryService;

    @Autowired
    private OrderOperateService orderOperateService;

    @ApiOperation(value = "交货单分页查询", notes = "交货单分页查询")
    @RequestMapping(value = "queryPage", method = RequestMethod.POST)
    public RestResult<PageResult<OrderDeliverInfo>> queryDeliverPage(@RequestBody OrderDeliverQueryPage orderDeliverQueryPage) {
        return orderQueryService.queryDeliverPage(orderDeliverQueryPage);
    }

    @ApiOperation(value = "根据规则查询可以合并的订单")
    @RequestMapping(value = "queryOrderPageByMergeRule", method = RequestMethod.POST)
    public RestResult<List<OrderDeliverInfo>> queryOrderByMergeRule(@RequestBody OrderDeliverQueryPage request) {
        return orderQueryService.queryOrderByMergeRule(request);
    }

    @ApiOperation(value = "交货单商品信息查询")
    @RequestMapping(value = "queryDeliverDetail", method = RequestMethod.POST)
    public RestResult<List<OrderDeliverDetail>> queryDeliverDetail(@RequestBody OrderDeliverDetailRequest request) {
        return orderQueryService.queryDeliverDetail(request);
    }

    @ApiOperation(value = "确认发货", notes = "商家或供应商看到打包快递包裹，填写相应的快递单号，此交货单变成已发货状态")
    @RequestMapping(value = "confirmShip", method = RequestMethod.POST)
    public RestResult<String> confirmShip(@RequestBody SendGoodsRequest request) {
        return orderOperateService.sendGoods(request);
    }

    @ApiOperation(value = "交货单商品信息查询")
    @RequestMapping(value = "queryOrderNoByDeliverNo", method = RequestMethod.POST)
    public RestResult queryOrderNoByDeliverNo(@RequestBody OrderDeliverDetailRequest request) {
        return orderQueryService.queryOrderNoByDeliverNo(request);
    }



}
